//
//  XMGPublishViewController.m
//  Publish
//
//  Created by MB.Lee on 17/1/16.
//  Copyright © 2017年 com.coubi.ii. All rights reserved.
//

#import "XMGPublishViewController.h"
#import "XMGButton.h"

@interface XMGPublishViewController ()

@end

@implementation XMGPublishViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 添加标签
    UIImageView *sloganView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"app_slogan"]];
    
    sloganView.y = XMGScreenH *0.2;
    sloganView.centerX = XMGScreenW * 0.5;
//    sloganView.centerY = XMGScreenH *0.5;
    [self.view addSubview:sloganView];
    
    //数据
    NSArray *images = @[@"publish-video",@"publish-picture",@"publish-text",@"publish-audio",@"publish-review",@"publish-offline"];
    NSArray *titles = @[@"发视频",@"发图片",@"发声音",@"发段子",@"审帖",@"离线下载"];
    
    // 中间的6个按钮
    CGFloat buttonW = 72; //取决于图片
    CGFloat buttonH = buttonW +30; //
    CGFloat buttonStartY = (XMGScreenH - 2 * buttonH) * 0.5;
    int maxCols = 3;
    CGFloat buttonStartX =20;
    CGFloat buttonMargin = (XMGScreenW - 2 * buttonStartX -maxCols * buttonW) / (maxCols - 1);
    
    for (int i = 0; i < images.count; i ++) {
        XMGButton *button = [[XMGButton alloc]init];
        button.titleLabel.font = [UIFont systemFontOfSize:15];
        //设置内容
        [button setTitle:titles[i] forState:0];
        [button setTitleColor:[UIColor blackColor] forState:0];
        [button setImage:[UIImage imageNamed:images[i]] forState:0];
        
        button.width = buttonW;
        button.height = buttonH;
       
        
        //九宫格
        int row = i / maxCols;
        int col = i % maxCols;
        button.x = buttonStartX + (buttonW + buttonMargin) * col;
        button.y = buttonStartY + row * buttonH;
        [self.view addSubview:button];
    }
}
- (IBAction)cancel:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
    
}
@end
